<template>
  <div :class="['loading-page', loadingExit ? 'exit' : '']" v-if="showLoading">
    <div class="loading-box">{{ tipText }}</div>
  </div>
</template>

<script>
export default {
  data () {
    return {
    }
  },
  computed: {
    loading () {
      return this.$store.getters.stuCTLoading
    },
    loadingExit () {
      return this.$store.getters.stuCTLoadingExit
    },
    tipText () {
      let _text = ''
      if (this.loading) {
        _text = '即将进入实验环境...'
      }
      if (this.loadingExit) {
        _text = '正在退出实验环境...'
      }
      return _text
    },
    showLoading () {
      return this.loading || this.loadingExit
    }
  },
  mounted () { }
}
</script>
<style scoped lang="scss">
@keyframes animateNow {
  from {
    color: rgba(0, 0, 0, 1);
    background-color: rgba(255, 255, 255, 0.9);
  }
  to {
    color: rgba(255, 255, 255, 1);
    background-color: rgba(0, 0, 0, 0.9);
  }
}
@keyframes animateLeave {
  from {
    color: rgba(255, 255, 255, 1);
    background-color: rgba(0, 0, 0, 0.9);
  }
  to {
    color: rgba(255, 255, 255, 0.8);
    background-color: rgba(255, 255, 255, 0.9);
  }
}
.loading-page {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  animation: animateNow 3s 1;
  color: rgba(255, 255, 255, 1);
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 3000;
  .loading-box {
    height: 120px;
    line-height: 220px;
    width: 280px;
    font-size: 14px;
    text-align: center;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: url(../../assets/img/loading/dark.gif) no-repeat top center;
  }
  &.exit {
    color: rgba(255, 255, 255, 0.8);
    background-color: rgba(255, 255, 255, 0.9);
    animation: animateLeave 3s 1;
    .loading-box {
      background: url(../../assets/img/loading/light.gif) no-repeat top center;
    }
  }
}
</style>